package com.android.internal.telephony;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Log;

public class FxTelephony
{
	private static final String TAG = "FxTelephony";
	
	public static ITelephony getITelelephony(Context context)
	{
		TelephonyManager tManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
		Class<TelephonyManager> c = TelephonyManager.class;
		Method getITelephonyMethod = null;
		try
		{
			getITelephonyMethod = c.getDeclaredMethod("getITelephony",
					(Class[]) null);
			getITelephonyMethod.setAccessible(true);
		} catch (NoSuchMethodException e)
		{
			Log.e(TAG, "No method getDeclaredMethod ", e);
		}
		ITelephony phone = null;
		try
		{
			phone = (ITelephony) getITelephonyMethod.invoke(tManager,
					(Object[]) null);
		} catch (IllegalAccessException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return phone;
	}
}
